<?php

defined('SYSPATH') or die('Access error!');

class Controller_Shop extends Controller_Shop_Main
{

    private $goods;

    public function before()
    {
        parent::before();
        $this->goods = Model::factory('shop_goods');
        I18n::set_current_file('shop');
    }

     //获取商城的首页
    public function action_index()
    {
        //获取首页需要的产品分类
        $this->template->assign('category_list',$this->get_sub_category());
        //获取首页的幻灯片
        $this->template->assign('top_slider_banner',Model::factory('ads')->get_ads_by_category_id(106));
        //获取推荐的店铺
        $this->template->assign('recommand_store', Model::factory('shop_store')->get_recommend_store());
        //获取首页的最新产品
        $recommend_new_goods = Model::factory('shop_goods')->get_category_recommend_goods('new',''," g.account_type='points'",3);
        $this->template->assign('recommend_new_goods',$recommend_new_goods);
        
        //测试的幻灯片、
        $this->template->assign('gongcheng_slider_banner',Model::factory('ads')->get_ads_by_category_id(136));
        $this->template->assign('tuzhi_slider_banner',Model::factory('ads')->get_ads_by_category_id(137));
        $this->template->assign('cailiao_slider_banner',Model::factory('ads')->get_ads_by_category_id(138));
        
        //临时的测试数据
        $new_goods = Model::factory('shop_goods')->get_goods_list('',10);
        $this->template->assign('news_goods',$new_goods['list']);
        
        
        //工程相关的测试数据
        $gongcheng_goods = Model::factory('shop_goods')->get_list_by_category_id(111,10);
        $this->template->assign('gongcheng_goods',$gongcheng_goods['list']);
        
        //图纸相关的测试数据
        $tuzhi_goods = Model::factory('shop_goods')->get_list_by_category_id(116,10);
        $this->template->assign('tuzhi_goods',$tuzhi_goods['list']);
        
        
        //材料相关的测试数据
        $cailiao_goods = Model::factory('shop_goods')->get_list_by_category_id(117,10);
        $this->template->assign('cailiao_goods',$cailiao_goods['list']);
        
        /**
         * 工程相关的分类
         *  1:总共的分类
         *  2：推荐分类
         */
         $project_all_category = $this->get_double_category(111);
         $this->template->assign('project_all_category',$project_all_category);
         
         
         /**
         * 图纸相关的分类
         *  1:总共的分类
         *  2：推荐分类
         */
         $tuzhi_all_category= $this->get_double_category(116);
         $this->template->assign('tuzhi_all_category',$tuzhi_all_category);
         
         
         /**
         * 材料相关的分类
         *  1:总共的分类
         *  2：推荐分类
         */
         $cailiao_all_category = $this->get_double_category(117);
         $this->template->assign('cailiao_all_category',$cailiao_all_category);
        
         
         //获取商城公告
         $shop_announcement = Model::factory('news')->get_allnews_list_by_category_id(134);
        $this->template->assign('shop_announcement' ,$shop_announcement['list']);
        
        
        //显示首页
        $this->template->view('shop_index');
        
    }

}